<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>个人中心</title>
      <link rel="stylesheet" type="text/css" href="../../css/api.css" />
      <link rel="stylesheet" type="text/css" href="../../css/common.css" />
      <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    	<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
      <style>
          html, body {width: 100%;min-height: 100%;background: #F3EFEE;}
          .aui-active .aui-bar-tab-label{
            color: #f5a51c
          }
          .login {height:240px;background-image: -webkit-linear-gradient(0deg, #f5c674, #ed824c);/*background-image: url(../../image/personal_bkg.jpg);background-repeat: no-repeat; background-size: cover;*/position: relative;}
      	.login .personal_logo {width: 4rem;height: 4rem;border-radius: 50%;margin: 0 auto 9px;/*position: absolute; top: 60px; left: 20px;*/}
      		.login .userinfo {position: absolute; top: 60px;text-align: center; left: 0; right: 0;}
      		.login .userinfo .title {font-size: 0.8rem; color: #fff;}

      		/* 设置条目 */
      		.item {height: 3rem;line-height: 3rem;padding-left: 0.7rem;background-color: #fff;}
      		.item_ico {float: left;width: 2.3rem;padding: 0.7rem 0.7rem 0.7rem 0;}
      		.item_arrow {float: right;width: 1.5rem;padding: 1rem 0.7rem 1rem 0;}
      		.item span {font-size: 0.7rem;}
          [v-cloak]{
            display: none
          }
          .aui-toast-content{
            color: #fff;
          }
          .aui-refresh-content {
            min-height: calc(100vh - 0.5rem)
          }
      </style>
  </head>
  <body>
<div id="app" v-cloak>


  <div class="aui-refresh-content">
    <div class="store_main"  style="	margin-top: 10px;" v-for="(value,index) in msgList" @click="getAddress(value)">
      <div class="store_content">
        <div>{{value.consignee}} <span style="font-size:0.6rem;color:#999;" v-if="value.default==1">( 默认地址 )</span></div>
        <div>{{value.telephone}}</div>
      </div>
      <div class="store_main_address_text">
        {{value.provice}}{{value.city}}{{value.district}}{{value.place}}
      </div>
      <div class="store_content_one">
        <div class="store_content_address">
          <!-- <span style="border:1px solid #999;border-radius:50%" class="store_address_content" v-if="value.default==2"></span>
          <img src="../../image/my/m28.png" alt="" class="store_address_content"  v-else-if="value.default==1">
          <div class="store_color_text" style="color:#999">默认地址</div> -->
        </div>
        <div class="store_content_two">
          <div class="store_content_text_one">
            <img src="../../image/my/m27.png" alt=""  class="store_address_content">

            <div class="store_color_text" @click="editorAdd(value.a_id,value.default, $event)">编辑</div>
          </div>
          <div class="store_content_delete">
            <img src="../../image/my/m29.png" alt=""  class="store_address_content">
            <div class="store_color_text" @click="delectMsg(value.a_id, $event)">删除</div>
          </div>
        </div>
      </div>
    </div>
  </div>
<div>
<!--弹框-->
</div>
<div class="store_footer_address" onclick="storeClick()">
  <img src="../../image/my/m30.png" alt="" class="store_address_content">
  <div class="store_color_text_two">添加地址</div>
</div>
  </body>
  <script type="text/javascript" src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/zepto.js"></script>
  <script type="text/javascript" src="../../script/vue.min.js"></script>
  <script type="text/javascript" src="../../script/utils.js"></script>
  <script type="text/javascript" src="../../script/common.js"></script>
  <script type="text/javascript" src="../../script/aui-tab.js"></script>
  <script type="text/javascript" src="../../script/aui-scroll.js"></script>
  <script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
  <script type="text/javascript" src="../../script/aui-popup.js"></script>
  <script type="text/javascript" src="../../script/aui-dialog.js"></script>
  <script type="text/javascript" src="../../script/aui-toast.js"></script>
  <script type="text/javascript">

      function storeClick(){
        api.openWin({
            name: 'shappingAdd',
            url: './headerone.html',
            pageParam: {
                msg:'添加收货地址',
                url:'./shoppingAdd.html'
            }
        });

      }
  apiready = function(){
    var dialog = new auiDialog({});
    var toast = new auiToast({});
    new Vue({
      el:'#app',
      data:{
        msgList:[]
      },
      methods:{
        //刷新
      setRefresh:function() {
        $this = this
            var pullRefresh = new auiPullToRefresh({
                container: document.querySelector('.aui-refresh-content'),
                triggerDistance: 100
            }, function(ret) {

                if (ret.status == "success") {
                    setTimeout(function() {
                        $this.addressList()
                        pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                    }, 500)
                }
            })
        },
      delectMsg:function(index, ev){
        ev.stopPropagation()
          dialog.alert({
                  title:"地址删除",
                  msg:'您确定要删除该收货地址？',
                  buttons:['取消','确定']
              },function(ret){
                if(ret.buttonIndex == 2){
                    api.ajax({
                        url: window.Url.Freeucenter_changeAddress,
                        method: 'post',
                        data: {
                            values: {
                                token:$api.getStorage('token'),
                                type:3,
                                a_id:index
                            }
                        }
                    },function(ret, err){
                        if (ret) {
                            // alert(ret.info);
                            if (api.pageParam.id == index) {
                              api.sendEvent({
                                  name: 'changeAddress',
                                  extra: {
                                      value: null,
                                  }
                              })
                            }

                            window.location.reload();
                        } else {
                            toast.fail({
                              titile:"取消删除",
                              duration:2000
                            });
                        }
                    });

                }else if(ret.buttonIndex == 1){

                }
              })
        },
        //地址列表
        addressList:function(){
          var _this = this;
          api.ajax({
              url: window.Url.Freeucenter_addressList,
              method: 'post',
              data: {
                  values: {
                    token:$api.getStorage('token'),
                  }
              }
          },function(ret, err){
            //console.log("地址列表数据---"+JSON.stringify(ret))
              if (ret.re == 1) {
                  _this.msgList = ret.data.list;
                  //alert(JSON.stringify(ret))
              } else {
                  // toast.fail({
                  //   titile:ret.info,
                  //   duration:2000
                  // });
              }
          });

        },
        //编辑页面
        editorAdd:function(index,value, ev){

            ev.stopPropagation()
           api.openWin({
               name: 'editorAdd',
               url: './editorAdd.html',
               pageParam: {
                    index:index,
                    value:value
               }
           });

        },
        getAddress :function(value) {
        //  console.log(JSON.stringify(value))
          api.sendEvent({
              name: 'changeAddress',
              extra: {
                  value: value,
              }
          })
          setTimeout(function () {
            api.closeWin({name: 'user_url'})
          },1000)
        }


      },
      mounted:function(){
          this.setRefresh();
          this.addressList();
      },
      updated:function(){


      }

    })
  }

  </script>
  </html>
